import 'dart:ui';

class SizeFit {
  static late double physicalWidth;
  static late double physicalHeight;
  static late double srceenWidth;
  static late double screenHeight;
  static late double dpr;
  static late double statusHeight;

  static late double _rpx;
  static late double _px;

  /// [standardSize] 标准尺寸， 默认 750
  static void initialize({double standardSize = 750}) {
    /// 到手机物理分辨率
    physicalWidth = window.physicalSize.width;
    physicalHeight = window.physicalSize.height;

    /// 屏幕大小 逻辑分辨率
    dpr = window.devicePixelRatio;
    srceenWidth = physicalWidth / dpr;
    screenHeight = physicalHeight / dpr;

    statusHeight = window.padding.top / dpr;

    // 计算 rpx
    _rpx = srceenWidth / standardSize;

    // 计算 px
    _px = srceenWidth / standardSize * 2;
  }

  static double Rpx(double size) {
    return _rpx * size;
  }

  static double Px(double size) {
    return _px * 2;
  }
}